//
//  GKBaseTableViewController.swift
//  MicroBlogFunc
//
//  Created by GK on 16/4/8.
//  Copyright © 2016年 GK. All rights reserved.
//

import UIKit

class GKBaseTableViewController: UITableViewController {
    
    var userLogin = GKUserAccountViewModel.shareInstance.userLogin
    
    override func loadView() {
        userLogin ? super.loadView() : setupVistorView()
    }
    
    //设置访客视图
    private func setupVistorView()
    {
        self.view = visitorView
        visitorView.delegate = self
        if self is GKHomeTableViewController
        {
            visitorView.startRotation()
        }
        else if self is GKMessageTableViewController
        {
            visitorView.setVisitorViewInfo("登录后，别人评论你的微博，发给你的消息，都会在这里收到通知", imageName: "visitordiscover_image_message")
        }
        else if self is GKDiscoverTableViewController
        {
            visitorView.setVisitorViewInfo("登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过", imageName: "visitordiscover_image_message")
        }
        else if self is GKProfileTableViewController
        {
            visitorView.setVisitorViewInfo("登录后，你的微博、相册、个人资料会显示在这里，展示给别人", imageName: "visitordiscover_image_profile")
        }
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(visitorViewDidClickBtnRegister))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(visitorViewDidClickBtnLogin))
    }

    
   
    
    //懒加载访客视图
    private lazy var visitorView: GKVisitorView = GKVisitorView()
    
}

extension GKBaseTableViewController:GKVisitorViewDelegate{
    //代理方法
    func visitorViewDidClickBtnRegister()
    {
        print("点击注册按钮")
    }
    func visitorViewDidClickBtnLogin()
    {
        let OauthVC = GKOauthViewController()
        let anv = UINavigationController(rootViewController: OauthVC)
        self.presentViewController(anv, animated: true, completion: nil)
    }
    
}








